<script setup>
import { inject, onMounted, onUnmounted, toRaw } from 'vue';
import { storeToRefs } from 'pinia';
import EventBus from '../../common/EventBus';
import { useLocalMusicStore } from '../store/localMusicStore';
import { useAppCommonStore } from '../store/appCommonStore';
import { usePlatformStore } from '../store/platformStore';
import { usePlayStore } from '../store/playStore';
import { useUserProfileStore } from '../store/userProfileStore';
import { useRecentsStore } from '../store/recentsStore';
import { Playlist } from '../../common/Playlist';
import { useSettingStore } from '../store/settingStore';
import { onEvents, emitEvents, offEvents } from '../../common/EventBusWrapper';
import { ipcRendererSend, transformPath } from '../../common/Utils';



//TODO 整体设计比较乱，后续待梳理
const props = defineProps({
    posStyle: Object,
    data: Array
})

const { visitArtist, visitAlbum, visitCustomPlaylistCreate,
    visitCustomPlaylistEdit, visitBatchCustomPlaylist,
    visitLocalPlaylistCreate, visitTrack,
} = inject('appRoute')
const { playPlaylist } = inject('player')
const { showConfirm } = inject('apiExpose')

let currentDataType = -1

const { commonCtxItem, commonCtxMenuCacheItem } = storeToRefs(useAppCommonStore())
const { showToast, setCommonCtxMenuData, showFailToast,
    hideAllCtxMenus, setRouterCtxCacheItem, hideTrackResourceToolView, 
    toggleTrackResourceToolView, setWorkingTrackForResourceToolView,
    setTrackResourceToolViewPreviewMode,
} = useAppCommonStore()
const { playTrackLater, addTrack, removeTrack, addTracks, playTrack } = usePlayStore()
const { addFavoriteTrack, removeFavoriteSong, addFavoriteRadio,
    removeCustomPlaylist, removeFromCustomPlaylist,
    getCustomPlaylist, addToCustomPlaylist, moveToCustomPlaylist,
    removeFavoritePlaylist } = useUserProfileStore()
const { customPlaylists } = storeToRefs(useUserProfileStore())
const { addToLocalPlaylist, moveToLocalPlaylist, removeFromLocalPlaylist } = useLocalMusicStore()
const { localPlaylists } = storeToRefs(useLocalMusicStore())
const { removeRecentSong, } = useRecentsStore()
const { isLocalMusic, isWebDav, isNavidrome } = usePlatformStore()
const { isShowDialogBeforeDeleteCustomPlaylist, isSimpleLayout, isMiniLayout, } = storeToRefs(useSettingStore())
const { switchToFallbackLayout } = useSettingStore()



const toastAndHideMenu = (text, failed) => {
    if (failed) {
        showFailToast(text)
    } else {
        showToast(text)
    }
    hideAllCtxMenus()
}

const playItem = () => {
    playTrack(commonCtxMenuCacheItem.value)
    hideAllCtxMenus()
}

const addItemToQueue = () => {
    const cache = commonCtxMenuCacheItem.value
    if (Array.isArray(cache)) {
        addTracks(cache)
    } else {
        addTrack(cache)
    }
    toastAndHideMenu("歌曲添加成功")
}

const playItemLater = () => {
    playTrackLater(commonCtxMenuCacheItem.value) 
        && toastAndHideMenu("下一曲将为您播放")
}

const addFavoriteItem = () => {
    const track = commonCtxMenuCacheItem.value
    if (!track) return
    const { platform } = track
    if(isWebDav(platform) || isNavidrome(platform)) {
        return toastAndHideMenu('当前平台暂不支持收藏', true)
    }
    let text = "歌曲收藏成功", success = true
    if (Playlist.isFMRadioType(track)) {
        addFavoriteRadio(track)
        text = "FM电台收藏成功"
    } else if (isLocalMusic(platform)) {
        success = false
        text = "本地歌曲不支持收藏"
    } else {
        addFavoriteTrack(track)
    }
    if (success) emitEvents('track-refreshFavoritedState')
    toastAndHideMenu(text, !success)
}

//TODO
const isMenu = () => true

const isMultiArtists = () => {
    const { artist } = commonCtxMenuCacheItem.value
    return artist.length > 1
}

const visitItemArtist = (event) => {
    const { platform, artist } = commonCtxMenuCacheItem.value
    if (artist.length == 1) {
        visitArtist({ platform, item: artist[0], index: -1 })
    } else {
        emitEvents("artistListSubmenu-init")
        emitEvents("artistListSubmenu-show", event)
    }
}

const visitItemAlbum = () => {
    const { platform, album } = commonCtxMenuCacheItem.value
    visitAlbum({ platform, id: album.id, data: album })
}

const visitTrackDetail = () => {
    const data = toRaw(commonCtxMenuCacheItem.value)
    const { id, platform, title, cover, artist, album } = data
    if (Playlist.isFMRadioType(data)) return
    visitTrack({
        id, platform, title, cover, artist,
        artist: JSON.stringify(artist),
        album: JSON.stringify(album),
    }, () => setRouterCtxCacheItem(data))
}

const showInFolder = () => {
    const data = toRaw(commonCtxMenuCacheItem.value)
    if(!data) return 
    const { platform, url } = data
    if(!isLocalMusic(platform) || !url) return 
    ipcRendererSend('path-showInFolder', transformPath(url))
    hideAllCtxMenus()
}

const removeQueueItem = () => {
    const track = commonCtxMenuCacheItem.value
    removeTrack(track)
    let msg = "歌曲已删除"
    if (Playlist.isFMRadioType(track)) msg = "电台已删除"
    else if (Playlist.isAnchorRadioType(track)) msg = "音频已删除"
    toastAndHideMenu(msg)
    return true
}

const removeLocalItem = (item, index) => {
    const track = commonCtxMenuCacheItem.value
    const { id } = commonCtxItem.value || { id: track.pid }
    removeFromLocalPlaylist(id, track)
    toastAndHideMenu("歌曲已删除")
    //if (currentDataType == 11) emitEvents('ctxMenu-removeFromLocal')
    emitEvents('ctxMenu-removeFromLocal')
    return true
}

const removeFavoriteItem = () => {
    const { id, platform } = commonCtxMenuCacheItem.value
    removeFavoriteSong(id, platform)
    toastAndHideMenu("歌曲已取消收藏")
    return true
}

const playCustom = () => {
    const { id } = commonCtxMenuCacheItem.value
    const playlist = getCustomPlaylist(id)
    doPlayPlaylist(playlist)
}

const visitCustomEdit = () => {
    const { id } = commonCtxMenuCacheItem.value
    visitCustomPlaylistEdit(id)
}

const visitBatchCustom = () => {
    const { id } = commonCtxMenuCacheItem.value
    visitBatchCustomPlaylist(id, 'userhome')
}

//删除创建的歌单
const removeCustom = async () => {
    if (isShowDialogBeforeDeleteCustomPlaylist.value) {
        const ok = await showConfirm('确定要删除歌单吗？')
        if(!ok) return
    }

    const { id } = commonCtxMenuCacheItem.value
    removeCustomPlaylist(id)
    emitEvents({ 'customPlaylist-removed': id })
    toastAndHideMenu("歌单已删除")
    return true
}

//TODO 从创建的歌单里删除歌曲
const removeFromCustom = () => {
    const { id } = commonCtxItem.value // Playlist
    const track = commonCtxMenuCacheItem.value
    removeFromCustomPlaylist(id, track)
    toastAndHideMenu("歌曲已删除")
    return true
}

const removeFromRecent = () => {
    removeRecentSong(commonCtxMenuCacheItem.value)
    toastAndHideMenu("歌曲记录已删除")
    return true
}

//TODO
const doShowAddToListSubmenu = (event, mode, dataType) => {
    emitEvents("addToListSubmenu-init", {
        mode,
        dataType: (dataType || currentDataType),
        callback: ({ total }) => {
            emitEvents("addToListSubmenu-show", { event, total })
        }
    })
}

const showAddToList = (event, mode) => {
    const track = commonCtxMenuCacheItem.value
    if (!track || Playlist.isFMRadioType(track)) return
    const { platform } = track
    if (isWebDav(platform) || isNavidrome(platform)) return 
    const dataType = isLocalMusic(platform) ? 10 : currentDataType
    doShowAddToListSubmenu(event, mode, dataType)
    return true
}

const doPlayPlaylist = (playlist) => {
    hideAllCtxMenus()
    playPlaylist(playlist)
}

const removePlaylistFromFavorite = () => {
    const { id, platform } = commonCtxMenuCacheItem.value
    removeFavoritePlaylist(id, platform)
    toastAndHideMenu("歌单已取消收藏")
    emitEvents("refresh-favorite")
    return true
}

const visitPlaylistCreate = () => {
    isLocalMusicType(currentDataType) ? visitLocalPlaylistCreate() : visitCustomPlaylistCreate()
}

const showTrackResourceToolView = () => {
    if (isSimpleLayout.value || isMiniLayout.value) switchToFallbackLayout()

    hideAllCtxMenus(false)
    hideTrackResourceToolView()
    setWorkingTrackForResourceToolView(commonCtxMenuCacheItem.value)
    setTrackResourceToolViewPreviewMode(false)
    toggleTrackResourceToolView()
}


const MenuItems = {
    sp: {
        separator: true
    },
    play: {
        name: '播放',
        icon: '<svg width="16" height="16" viewBox="0 0 139 139" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M117.037,61.441L36.333,14.846c-2.467-1.424-5.502-1.424-7.972,0c-2.463,1.423-3.982,4.056-3.982,6.903v93.188  c0,2.848,1.522,5.479,3.982,6.9c1.236,0.713,2.61,1.067,3.986,1.067c1.374,0,2.751-0.354,3.983-1.067l80.704-46.594  c2.466-1.422,3.984-4.054,3.984-6.9C121.023,65.497,119.502,62.866,117.037,61.441z"/></svg>',
        action: playItem,
    },
    playLater: {
        name: '下一曲播放',
        icon: '<svg width="16" height="16" viewBox="0 0 1016.14 1016.1" xmlns="http://www.w3.org/2000/svg" ><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M855.35,134.55q23.42-24,46.82-47.91c6.59-6.74,14.31-8.93,23.23-5.48,8.24,3.18,12.69,10.31,12.7,20.15q.06,57,0,114,0,33.49,0,67c0,14-8.28,22.46-22.36,22.47q-90.5.09-181,0c-10.7,0-17.88-4.41-21.12-12.85-3.55-9.25-.61-16.75,6.14-23.5,20.64-20.6,41.13-41.35,61.93-62.31a20,20,0,0,0-2-2.21c-57.49-50.33-123.7-83-199-95.71C467.07,89,362.61,112.61,269.37,180.43c-83.05,60.41-137,141.45-157.78,242.16-26.92,130.72,2.28,248.84,89,350.94,56.55,66.57,128.32,109.92,213.54,130C605,948.46,798.31,854.19,880.52,676.35A390.93,390.93,0,0,0,914.21,556.2c3.36-29.3,24.65-48.78,52.66-48,28.86.77,52.2,27.58,49,56.25-23.63,209.77-175.59,383.91-380.38,435.94a507.7,507.7,0,0,1-178.46,13C250.67,992.07,76.68,846.67,19.72,647.81A498.26,498.26,0,0,1,2.91,455.41C17.55,320.13,77.17,208.27,180.28,120,246.77,63,324.09,27.56,409.73,10.1A490.72,490.72,0,0,1,556.41,2.33q157.29,15.45,279.36,116c6.05,5,11.88,10.21,17.82,15.31.11.09.31.08.46.11Z"/><path d="M407.78,508q0-91.2,0-182.41c0-3.14,0-6.45.94-9.38,3.77-11.85,19-15.17,28-6.11,5.28,5.31,10.19,11,15.25,16.53Q528.83,410.82,605.63,495c7.79,8.54,8,16.88.35,25.32q-83.93,92.22-168,184.33c-8.22,9-20.92,9-27-.47-2.24-3.5-3.13-8.43-3.14-12.71-.2-56.64-.14-113.28-.14-169.92Z"/></g></g></svg>',
        action: playItemLater,
    },
    addToQueue: {
        name: '当前播放',
        icon: '<svg width="13" height="13" viewBox="0 0 682.28 597.06" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M597.41,348.87v-7.12q0-148.73,0-297.45c0-21.61,12.87-38.33,33-43.16,25.6-6.14,51,13.32,51.67,39.64.14,5.33.07,10.66.07,16,0,136.81.29,273.62-.14,410.42-.17,54.89-25.81,95.18-75.43,118.3-76.43,35.63-167.21-14.9-178.41-98.26C418.79,417.15,465.4,354,535,342.85a119,119,0,0,1,56.75,4.31C593.32,347.67,594.9,348.11,597.41,348.87Z"/><path d="M255.64,84.82q-104.73,0-209.46.06c-13.1,0-24.79-3.21-33.93-12.94C.19,59.1-3.13,44,3,27.57S21.6,2,39.19.34c2.65-.25,5.32-.29,8-.29Q255.89,0,464.6,0c9.48,0,18.54,1.16,26.81,6.3,15.55,9.68,23.33,28.26,19,45.77-4.53,18.37-19.25,31-37.85,32.44-3.15.24-6.32.29-9.48.29Q359.36,84.84,255.64,84.82Z"/><path d="M234.76,255.4q-95.46,0-190.92,0c-21.35,0-38.21-13.2-42.57-32.94A42.4,42.4,0,0,1,41,170.69c1.33-.06,2.66-.07,4-.07q189.66,0,379.33,0c21.48,0,38,12.15,43.2,31.67,7.08,26.38-12.46,52.85-39.81,53-64.3.27-128.61.09-192.91.09Z"/><path d="M170.39,341.48c42.81,0,85.62-.11,128.42,0,21.15.08,38,14.74,41.44,35.38a42.3,42.3,0,0,1-40.09,49.26c-1.33.07-2.67.07-4,.07q-125.67,0-251.35,0C24.12,426.22,8,414.9,2.16,396.47c-8.51-26.86,11.14-54.69,39.31-54.89,43-.3,85.94-.08,128.92-.08Z"/><path d="M170.48,596.82c-41.64,0-83.28-.08-124.92,0-17.84,0-31.81-6.75-40.39-22.64-14.51-26.86,3.62-59.55,34.07-61.89,2.32-.18,4.66-.28,7-.28q124.41,0,248.84-.06c18.44,0,32.79,6.84,41.31,23.55,13.68,26.81-4.47,58.93-34.5,60.88-12.44.81-25,.37-37.46.39Q217.46,596.87,170.48,596.82Z"/></g></g></svg>',
        action: addItemToQueue,
    },
    addToList: {
        name: '添加到',
        //icon: '<svg width="16" height="16" viewBox="0 0 768.02 554.57" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M341.9,0q148,0,296,0C659,0,675,11.28,680.8,30.05c8.34,26.78-11.43,54.43-39.45,55.18-1.17,0-2.33,0-3.5,0q-296.46,0-592.93,0C22.37,85.25,5.32,71.87.87,50.78-4.36,26,14.59,1.39,39.94.12c2.49-.13,5-.11,7.5-.11Z"/><path d="M554.64,426.5h-6.72c-26.49,0-53,.17-79.47-.1a41.87,41.87,0,0,1-39.06-27.7,42.4,42.4,0,0,1,11.2-46.19,41.85,41.85,0,0,1,29.11-11.25q39.49,0,79,0h6V335c0-26-.12-52,0-78,.15-25.3,19.44-44.3,44.06-43.72,23.23.55,41.24,19.54,41.37,43.92.13,25.82,0,51.65,0,77.48v6.57h5.67c26.65,0,53.31-.11,80,.05,20.38.12,37.94,14.9,41.51,34.49,3.74,20.57-7.15,40.65-26.59,47.73a53.72,53.72,0,0,1-17.56,2.85c-25.66.3-51.32.13-77,.13h-6v6.36c0,26,.1,52,0,78-.11,20.74-13.1,37.68-32.17,42.41-27.42,6.8-53-13.28-53.24-42.11-.22-26-.05-52-.05-78Z"/><path d="M234.37,256q-94.73,0-189.44,0c-21.55,0-38.62-12.68-43.5-32.09-6.74-26.8,12.45-52.1,40.47-53.35,1.33-.06,2.67-.05,4-.05H423.78c21.17,0,37.53,11.12,43.49,29.46,9.15,28.13-11.52,55.87-42,56-36.32.15-72.64,0-109,0Z"/><path d="M170.91,426.5c-42.48,0-85,.07-127.45,0-20.94-.06-37.61-13.2-42.21-32.85-6.18-26.41,13.5-52,40.6-52.3,23.82-.27,47.65-.07,71.47-.07q92.46,0,184.93,0c24.55,0,43.52,19.37,43.12,43.58-.38,23.41-19.15,41.53-43.51,41.61-40,.12-80,0-120,0Z"/></g></g></svg>',
        icon: '<svg width="14" height="14" viewBox="0 0 682.65 682.74" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M298.59,384.15h-7.06q-123.24,0-246.49,0c-21.63,0-38.69-12.57-43.64-31.94-7-27.56,13.21-53.29,42.33-53.51,25.33-.18,50.66,0,76,0H298.59v-6.44q0-123.49,0-247c0-20.39,10.77-36.44,28.49-42.71C355-7.34,383.55,13,384,43.16c.26,16.33,0,32.67,0,49V298.65h6.82q123.49,0,247,0c21.52,0,38.61,12.77,43.43,32.19,6.75,27.26-13.06,52.7-41.62,53.25-11.16.22-22.33,0-33.49,0H384.09v6.69q0,123.5,0,247c0,21.59-12.66,38.65-32.06,43.53-27.59,6.95-53.24-13.31-53.39-42.46-.17-32.66,0-65.33,0-98V384.15Z" /></g></g></svg>',
        menu: isMenu,
        action: showAddToList,
    },
    addToListNoQueue: () => ({
        name: '添加到',
        //icon: '<svg width="16" height="16" style="transform: translateY(1px);" viewBox="0 0 768.02 554.57" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M341.9,0q148,0,296,0C659,0,675,11.28,680.8,30.05c8.34,26.78-11.43,54.43-39.45,55.18-1.17,0-2.33,0-3.5,0q-296.46,0-592.93,0C22.37,85.25,5.32,71.87.87,50.78-4.36,26,14.59,1.39,39.94.12c2.49-.13,5-.11,7.5-.11Z"/><path d="M554.64,426.5h-6.72c-26.49,0-53,.17-79.47-.1a41.87,41.87,0,0,1-39.06-27.7,42.4,42.4,0,0,1,11.2-46.19,41.85,41.85,0,0,1,29.11-11.25q39.49,0,79,0h6V335c0-26-.12-52,0-78,.15-25.3,19.44-44.3,44.06-43.72,23.23.55,41.24,19.54,41.37,43.92.13,25.82,0,51.65,0,77.48v6.57h5.67c26.65,0,53.31-.11,80,.05,20.38.12,37.94,14.9,41.51,34.49,3.74,20.57-7.15,40.65-26.59,47.73a53.72,53.72,0,0,1-17.56,2.85c-25.66.3-51.32.13-77,.13h-6v6.36c0,26,.1,52,0,78-.11,20.74-13.1,37.68-32.17,42.41-27.42,6.8-53-13.28-53.24-42.11-.22-26-.05-52-.05-78Z"/><path d="M234.37,256q-94.73,0-189.44,0c-21.55,0-38.62-12.68-43.5-32.09-6.74-26.8,12.45-52.1,40.47-53.35,1.33-.06,2.67-.05,4-.05H423.78c21.17,0,37.53,11.12,43.49,29.46,9.15,28.13-11.52,55.87-42,56-36.32.15-72.64,0-109,0Z"/><path d="M170.91,426.5c-42.48,0-85,.07-127.45,0-20.94-.06-37.61-13.2-42.21-32.85-6.18-26.41,13.5-52,40.6-52.3,23.82-.27,47.65-.07,71.47-.07q92.46,0,184.93,0c24.55,0,43.52,19.37,43.12,43.58-.38,23.41-19.15,41.53-43.51,41.61-40,.12-80,0-120,0Z"/></g></g></svg>',
        icon: '<svg width="14" height="14" viewBox="0 0 682.65 682.74" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M298.59,384.15h-7.06q-123.24,0-246.49,0c-21.63,0-38.69-12.57-43.64-31.94-7-27.56,13.21-53.29,42.33-53.51,25.33-.18,50.66,0,76,0H298.59v-6.44q0-123.49,0-247c0-20.39,10.77-36.44,28.49-42.71C355-7.34,383.55,13,384,43.16c.26,16.33,0,32.67,0,49V298.65h6.82q123.49,0,247,0c21.52,0,38.61,12.77,43.43,32.19,6.75,27.26-13.06,52.7-41.62,53.25-11.16.22-22.33,0-33.49,0H384.09v6.69q0,123.5,0,247c0,21.59-12.66,38.65-32.06,43.53-27.59,6.95-53.24-13.31-53.39-42.46-.17-32.66,0-65.33,0-98V384.15Z" /></g></g></svg>',
        menu: isMenu,
        action: (event) => showAddToList(event, 2),
    }),
    addAllToListNoQueue: () => ({
        name: '全部添加到',
        //icon: '<svg width="16" height="16" style="transform: translateY(1px);" viewBox="0 0 768.02 554.57" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M341.9,0q148,0,296,0C659,0,675,11.28,680.8,30.05c8.34,26.78-11.43,54.43-39.45,55.18-1.17,0-2.33,0-3.5,0q-296.46,0-592.93,0C22.37,85.25,5.32,71.87.87,50.78-4.36,26,14.59,1.39,39.94.12c2.49-.13,5-.11,7.5-.11Z"/><path d="M554.64,426.5h-6.72c-26.49,0-53,.17-79.47-.1a41.87,41.87,0,0,1-39.06-27.7,42.4,42.4,0,0,1,11.2-46.19,41.85,41.85,0,0,1,29.11-11.25q39.49,0,79,0h6V335c0-26-.12-52,0-78,.15-25.3,19.44-44.3,44.06-43.72,23.23.55,41.24,19.54,41.37,43.92.13,25.82,0,51.65,0,77.48v6.57h5.67c26.65,0,53.31-.11,80,.05,20.38.12,37.94,14.9,41.51,34.49,3.74,20.57-7.15,40.65-26.59,47.73a53.72,53.72,0,0,1-17.56,2.85c-25.66.3-51.32.13-77,.13h-6v6.36c0,26,.1,52,0,78-.11,20.74-13.1,37.68-32.17,42.41-27.42,6.8-53-13.28-53.24-42.11-.22-26-.05-52-.05-78Z"/><path d="M234.37,256q-94.73,0-189.44,0c-21.55,0-38.62-12.68-43.5-32.09-6.74-26.8,12.45-52.1,40.47-53.35,1.33-.06,2.67-.05,4-.05H423.78c21.17,0,37.53,11.12,43.49,29.46,9.15,28.13-11.52,55.87-42,56-36.32.15-72.64,0-109,0Z"/><path d="M170.91,426.5c-42.48,0-85,.07-127.45,0-20.94-.06-37.61-13.2-42.21-32.85-6.18-26.41,13.5-52,40.6-52.3,23.82-.27,47.65-.07,71.47-.07q92.46,0,184.93,0c24.55,0,43.52,19.37,43.12,43.58-.38,23.41-19.15,41.53-43.51,41.61-40,.12-80,0-120,0Z"/></g></g></svg>',
        icon: '<svg width="14" height="14" viewBox="0 0 682.65 682.74" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M298.59,384.15h-7.06q-123.24,0-246.49,0c-21.63,0-38.69-12.57-43.64-31.94-7-27.56,13.21-53.29,42.33-53.51,25.33-.18,50.66,0,76,0H298.59v-6.44q0-123.49,0-247c0-20.39,10.77-36.44,28.49-42.71C355-7.34,383.55,13,384,43.16c.26,16.33,0,32.67,0,49V298.65h6.82q123.49,0,247,0c21.52,0,38.61,12.77,43.43,32.19,6.75,27.26-13.06,52.7-41.62,53.25-11.16.22-22.33,0-33.49,0H384.09v6.69q0,123.5,0,247c0,21.59-12.66,38.65-32.06,43.53-27.59,6.95-53.24-13.31-53.39-42.46-.17-32.66,0-65.33,0-98V384.15Z" /></g></g></svg>',
        menu: isMenu,
        action: (event) => showAddToList(event, 3),
    }),
    moveToList: {
        name: '移动到',
        icon: '<svg width="16" height="16" style="transform: scale(0.98);" viewBox="0 0 896.41 896.43" xmlns="http://www.w3.org/2000/svg" ><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M415.82,109.83l-48,48.05q-11.67,11.67-23.34,23.33c-14.07,14-33.73,14.73-46.83,1.73s-12.53-32.9,1.73-47.17q59-59.06,118.08-118.09c2.82-2.83,5.51-5.8,8.4-8.56,12.57-12,32.28-12.27,44.62,0q64.28,64.05,128.23,128.43a31.73,31.73,0,0,1,0,45.37c-12.6,12.5-32.34,12.53-45.37-.36-22.87-22.61-45.53-45.44-68.25-68.21-1.29-1.3-2.32-2.85-4.48-3.71V415.9H786.3c-1.58-1.7-2.72-3-3.95-4.25-22.74-22.76-45.57-45.41-68.2-68.27-17.51-17.69-10.76-46.49,12.53-53.62,12.85-3.94,23.94-.4,33.33,9q55.34,55.33,110.67,110.65c5.3,5.3,10.7,10.51,16,15.83,12.84,12.93,13.06,32.88.24,45.72q-63.58,63.68-127.36,127.18c-13.4,13.34-33.4,13.48-46.1.58s-12.39-32.47.78-45.74q33.82-34.05,67.88-67.87a42.32,42.32,0,0,1,4.34-3.38l-.68-1.09H480.5V786.38c1.78-1.66,3.1-2.82,4.34-4.06,22.75-22.74,45.39-45.59,68.27-68.2,17.57-17.36,46-10.82,53.41,12.18,4.13,12.82.82,24-8.56,33.42Q563.39,794.43,528.69,829q-28.62,28.66-57.19,57.36c-13.28,13.32-33.2,13.4-46.44.15q-63.24-63.3-126.45-126.67c-15.18-15.23-13.55-38.16,3.41-49.93,13-9,29.71-7.37,41.5,4.36q34,33.84,67.88,67.87c1.28,1.27,2.3,2.8,4.44,3.56V480.48H110c1.59,1.68,2.73,2.93,3.92,4.13,22.74,22.75,45.56,45.42,68.2,68.26,16.12,16.26,12.33,41.91-7.47,51.9-12.65,6.39-27,4-37.65-6.56-15.15-15-30.17-30.16-45.27-45.23Q51,512.36,10.27,471.77C-3.29,458.26-3.46,438.41,10,425q63.14-63.06,126.31-126.1c12.29-12.27,29-14.12,42.24-4.83,16.7,11.76,18.39,34.58,3.47,49.61-22.55,22.71-45.23,45.27-67.85,67.91-1.25,1.25-2.43,2.57-4.12,4.37H415.82Z"/></g></g></svg>',
        menu: isMenu,
        action: (event) => showAddToList(event, 1),
    },
    addFavorite: {
        name: '收藏',
        icon: '<svg width="16" height="16" viewBox="0 0 1024 937.46" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M1024,299.77c-.89,7.24-1.74,14.5-2.67,21.74-5.4,41.95-19.53,81-39,118.35-24.74,47.39-56.62,89.8-91.22,130.27-48.69,57-101.85,109.6-156.46,160.77C661.69,799.26,588.19,867,514.93,935.05c-.85.78-1.75,1.49-2.85,2.41-1.09-.89-2.14-1.65-3.09-2.52q-101.8-92.36-203.56-184.77c-58.71-53.61-116.12-108.59-168.2-168.81-39.12-45.23-74.7-92.93-100.8-147.1-18.8-39-31.17-79.91-35.23-123.16-.32-3.45-.8-6.89-1.2-10.33v-36c1-7.74,1.79-15.5,2.86-23.23,8.06-57.93,30.88-109.28,71.21-151.7,67.09-70.55,150.24-98.35,246.11-86,75.62,9.71,138.64,44.83,189.43,101.75.74.82,1.61,1.52,2.53,2.39.91-1,1.61-1.66,2.26-2.4a297.6,297.6,0,0,1,98.07-74.34C690-5.4,769.66-11.19,849.33,21.27,948,61.45,1004.25,136.62,1021.1,241.55c1.24,7.69,1.95,15.47,2.9,23.21ZM922.22,282.9c-1.08-10.76-1.48-21.64-3.33-32.27-10-57.28-39.78-101.12-91.95-127.45-54.58-27.54-110.52-27-165.67-1.07-44.78,21.07-78.08,53.89-96.65,100.47-1.2,3-2.93,3.41-5.65,3.4-29.5-.06-59-.1-88.49.05-3.58,0-5.17-1.2-6.63-4.39C430.29,148.12,342.54,89.86,249.42,105.81c-41,7-76.09,25.21-103.36,56.83-38.87,45.08-49.77,97.9-40.53,155.58,5.72,35.66,20,68.21,38.16,99.15C171,463.93,205.43,505,242,544.39c57.44,61.87,119.67,118.78,182.1,175.48,28,25.43,56.23,50.62,84.27,76,5.68,5.15,6.89,5.4,12.43.28C568,752.47,615.47,709.05,662.35,665c54.55-51.26,108-103.64,156.07-161.17C846.69,470,872.66,434.6,892.47,395,910.12,359.76,921.42,322.79,922.22,282.9Z"/></g></g></svg>',
        action: addFavoriteItem,
    },
    share: {
        name: '分享',
        icon: '<svg width="16" height="16" viewBox="0 0 767.96 895.83" xmlns="http://www.w3.org/2000/svg" ><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M458.7,677.8,274.75,559.58c-35.29,34.33-77.25,51.15-126.42,47.61C104,604,67.35,584.86,38.16,551.38c-53.89-61.79-50.31-156.85,8.26-216.25,60.08-60.95,162.47-65.53,228.41.79L458.59,217.83c-17.32-49.24-14-96.72,13.09-141.57,19.67-32.52,47.82-55.37,83.9-67.49,75.65-25.39,155.7,5.8,193.1,74.7C785.34,151,768.21,236,708.87,284.05c-60.76,49.2-153.42,49.49-215.57-12.43l-184,118.25a161.11,161.11,0,0,1,0,115.78l184,118.23c64.15-64.7,163-61.37,223-6C774.44,671.56,785,760.17,740.5,825.46c-44.86,65.91-131.3,89-202.23,54.35C466.68,844.85,428.1,760.37,458.7,677.8ZM512,159.4a96,96,0,1,0,96.37-95.62A96.09,96.09,0,0,0,512,159.4Zm0,576a96,96,0,1,0,96.36-95.62A96.08,96.08,0,0,0,512,735.4ZM160.36,351.78A96,96,0,1,0,256,448.11,96,96,0,0,0,160.36,351.78Z"/></g></g></svg>',
        action: null,
    },
    visitArtist: {
        name: '查看歌手',
        icon: '<svg width="16" height="16" viewBox="0 0 810 854.54" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M385,0c117.88.3,213.35,96.08,213,213.66-.38,118.12-95.71,213.26-213.49,213.07s-213.49-96.16-213-213.58C172,95,267.43-.3,385,0Zm-.58,341.47c70.36.28,127.94-56.94,128.31-127.5a128,128,0,1,0-256-.64C256.5,283.64,313.83,341.19,384.37,341.47Z"/><path d="M640.7,682.51v-20q0-74,0-148c0-19.27,8.52-33,25.74-41.6,27.27-13.56,54.42-27.36,81.76-40.78,25.87-12.7,55.2,1.93,61,30.15,3.72,18-5.84,37.41-22.29,45.6-18.92,9.41-37.7,19.1-56.66,28.43-3.37,1.66-4.38,3.6-4.38,7.23q.17,107.74.09,215.48c0,46.09-36,88-81.81,93.46-20.79,2.51-42,3.79-62.43-2.85-38.64-12.58-61.61-39.33-68.54-79.37-.83-4.8.79-10.24,2.08-15.17a97.51,97.51,0,0,1,100-72.67C623.48,682.9,631.8,682.51,640.7,682.51Z"/><path d="M312.19,512q56.49,0,113,0c21.61,0,38.67,12.73,43.48,32.1,6.92,27.84-13.42,53.25-43,53.34-46.49.15-93,0-139.46,0-25.33,0-50.66-.34-76,.16-65,1.29-119.65,52.93-123.4,117.82-1.79,30.89-.74,61.95-.8,92.94,0,9.06-1.78,17.5-6.67,25.2a42.56,42.56,0,0,1-47,18.26C14.33,847,1,831.09.85,812.66c-.32-32.49-1.95-65.13.39-97.45,6.53-89.82,52.23-152.77,135-188.31,25.72-11,53.08-14.93,81-14.92Z"/></g></g></svg>',
        menu: isMultiArtists,
        action: visitItemArtist,
    },
    visitAlbum: {
        name: '查看专辑',
        icon: '<svg width="16" height="16" viewBox="0 0 853.47 853.5" xmlns="http://www.w3.org/2000/svg" ><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M426.8,0C662.36.12,853.54,191.36,853.47,426.8S662,853.64,426.67,853.5C191.13,853.35-.11,662.05,0,426.67.11,191.14,191.42-.12,426.8,0ZM85.5,426.47C85.26,615.09,238,767.94,426.71,768c188.49,0,341-152.31,341.26-341S615.52,85.53,426.76,85.5C238.23,85.47,85.75,237.82,85.5,426.47Z"/><path d="M426.46,256c-47.09,1-87.6,17.3-120.63,50.49-32.87,33-49,73.41-49.87,120.08H171.28c-3.29-136.12,114-257.59,255.18-255.36Z"/><path d="M512,426.48a85.66,85.66,0,1,1-85.11-85.83A85.42,85.42,0,0,1,512,426.48Z"/></g></g></svg>',
        action: visitItemAlbum,
    },
    visitTrack: {
        name: '歌曲详情',
        icon: '<svg width="16" height="16" viewBox="0 0 736 831.94" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M320,447.93V441.7q0-196.23,0-392.47c0-29.06,22.88-51.48,51.13-49,9.79.84,19.43,4.34,29,7.2Q549.54,52.05,698.89,96.94c22.84,6.85,36.94,24.46,37.11,46.39.24,31.8-29.73,55.44-60.32,46.71-39.82-11.37-79.4-23.6-119.08-35.5q-67.39-20.21-134.77-40.49c-1.72-.52-3.49-.89-5.82-1.47v6.77q0,252,0,503.95A208.19,208.19,0,0,1,244.9,828.59C134.4,848.76,26.46,775.72,4.19,665.71c-21.25-104.94,40.19-209.48,142.1-240.43,59.18-18,115.84-10.79,169.31,20.54,1,.59,2,1.18,3,1.76A9.82,9.82,0,0,0,320,447.93ZM207.87,511.85A112,112,0,1,0,320,623.58,112,112,0,0,0,207.87,511.85Z"/></g></g></svg>',
        action: visitTrackDetail,
    },
    showInFolder: {
        name: '查看目录',
        icon: '<svg width="16" height="16" style="transform: translateY(1px);" viewBox="0 0 870.27 700.5" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M0,604.32V99.2c.67-3.86,1.41-7.71,2-11.59C9.18,39,52.75.55,101.7.25,159-.11,216.36,0,273.69,0c25.8,0,48.64,8.41,68.48,24.88q46.9,39,93.69,78.06a14.83,14.83,0,0,0,10.38,3.78q28.74-.34,57.48-.37c55,0,110-.11,165,.07a207.6,207.6,0,0,1,30.85,2,101.72,101.72,0,0,1,85.67,95c.56,10.25.9,20.52,1.35,31,2.09.24,3.89.51,5.7.64,51.39,3.65,86.9,50.22,76,100.61-5.36,24.87-12,49.46-18.2,74.16q-28.44,113.81-57,227.57c-9.72,38.4-42,62.93-81.62,63-30.5,0-61,.16-91.49.15l-515-.15c-48.08,0-88.76-31.22-101.1-77.7C2.32,616.62,1.29,610.43,0,604.32Zm104.9,13.85c2.46.13,4.26.31,6,.31q298.5,0,597,.11c4.42,0,6-1.5,7-5.54Q751,468.21,787.3,323.43c1.69-6.77,1.49-7-5.6-7H201.2c-14.52,0-22.59,6.36-26.11,20.43q-31.43,125.67-62.85,251.35C109.79,598,107.43,607.83,104.9,618.17ZM704.49,234.73c0-7.11.21-13.26,0-19.39-.79-19.31-8.81-26.93-28-27q-61.73-.07-123.47-.16-61.49,0-123,.2c-13.46,0-25-4.5-35.23-13.06Q343,132.08,291.12,88.94c-5-4.16-10.57-7-17.22-7-15.15,0-30.3.07-45.46.08Q168.2,82,108,82c-16.46,0-25.72,9.19-25.78,25.59-.07,20.66-.16,41.32-.16,62q0,96.5,0,193v5.25a10.3,10.3,0,0,0,2-4.52C87.7,348.64,91.61,334,95,319.24c12.35-54.39,57.58-84.92,108.68-84.74,164.3.6,328.61.23,492.91.23Z"/></g></g></svg>',
        action: showInFolder
    },
    removeFromQueue: {
        name: '删除',
        icon: '<svg width="16" height="16" viewBox="0 0 256 256" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg"><path d="M1040,669H882c-12.79-4.93-17.16-14.62-17.1-27.83.26-52.77.11-105.55.11-158.32V477c-6,0-11.42-.32-16.84.09-6.54.48-11.66-1.39-15.17-7.08v-7c3.16-5.7,8-7.48,14.44-7.36,18.29.32,36.58.12,54.88.1,1.75,0,3.5-.16,5.48-.25,0-7.76,0-14.91,0-22.05a18.56,18.56,0,0,1,6.6-14.52c2.85-2.39,6.37-4,9.59-5.92h73c13.83,5.64,17.27,10.84,17.25,26.08,0,5.41,0,10.82,0,16.68h7.53c17.61,0,35.21.2,52.81-.12,6.43-.12,11.27,1.63,14.41,7.36v7c-3.5,5.7-8.63,7.56-15.17,7.08-5.41-.4-10.89-.09-16.84-.09v6.36c0,52.6-.15,105.2.11,157.8C1057.17,654.36,1052.81,664.08,1040,669ZM886.24,477.29V640.4c0,8.44-.49,7.34,7.11,7.35q67.95,0,135.9,0c6.51,0,6.52,0,6.52-6.43v-164Zm106.5-42.78H929.37v21h63.37Z" transform="translate(-833 -413)"/><path d="M950.29,562.2c0-13.47,0-26.94,0-40.41,0-7.94,4.25-12.84,10.82-12.77,6.36.07,10.59,5,10.6,12.52,0,27.28,0,54.55,0,81.83,0,5.13-1.71,9.17-6.5,11.36-7.39,3.36-14.87-2.16-14.94-11.11-.11-13.81,0-27.61,0-41.42Z" transform="translate(-833 -413)"/><path d="M1014.25,562.63c0,13.48,0,27,0,40.42,0,7.88-4.3,12.82-10.87,12.64-6.29-.18-10.35-5.13-10.36-12.75q0-41.16,0-82.33c0-5.91,3-9.91,8-11.26a10.29,10.29,0,0,1,11.85,5.16,16.06,16.06,0,0,1,1.33,6.71c.12,13.8.06,27.61.06,41.41Z" transform="translate(-833 -413)"/><path d="M929,562.53q0,21,0,41.92c0,4.8-2.09,8.39-6.49,10.29-4.21,1.81-8.49,1.25-11.43-2.23a13.57,13.57,0,0,1-3.17-8c-.23-28.1-.19-56.21-.12-84.32,0-6.74,4.63-11.34,10.74-11.19s10.41,4.78,10.44,11.59C929.05,534.59,929,548.56,929,562.53Z" transform="translate(-833 -413)"/></svg>',
        action: removeQueueItem,
    },
    removeFromLocal: {
        name: '删除',
        icon: '<svg width="16" height="16" viewBox="0 0 256 256" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg"><path d="M1040,669H882c-12.79-4.93-17.16-14.62-17.1-27.83.26-52.77.11-105.55.11-158.32V477c-6,0-11.42-.32-16.84.09-6.54.48-11.66-1.39-15.17-7.08v-7c3.16-5.7,8-7.48,14.44-7.36,18.29.32,36.58.12,54.88.1,1.75,0,3.5-.16,5.48-.25,0-7.76,0-14.91,0-22.05a18.56,18.56,0,0,1,6.6-14.52c2.85-2.39,6.37-4,9.59-5.92h73c13.83,5.64,17.27,10.84,17.25,26.08,0,5.41,0,10.82,0,16.68h7.53c17.61,0,35.21.2,52.81-.12,6.43-.12,11.27,1.63,14.41,7.36v7c-3.5,5.7-8.63,7.56-15.17,7.08-5.41-.4-10.89-.09-16.84-.09v6.36c0,52.6-.15,105.2.11,157.8C1057.17,654.36,1052.81,664.08,1040,669ZM886.24,477.29V640.4c0,8.44-.49,7.34,7.11,7.35q67.95,0,135.9,0c6.51,0,6.52,0,6.52-6.43v-164Zm106.5-42.78H929.37v21h63.37Z" transform="translate(-833 -413)"/><path d="M950.29,562.2c0-13.47,0-26.94,0-40.41,0-7.94,4.25-12.84,10.82-12.77,6.36.07,10.59,5,10.6,12.52,0,27.28,0,54.55,0,81.83,0,5.13-1.71,9.17-6.5,11.36-7.39,3.36-14.87-2.16-14.94-11.11-.11-13.81,0-27.61,0-41.42Z" transform="translate(-833 -413)"/><path d="M1014.25,562.63c0,13.48,0,27,0,40.42,0,7.88-4.3,12.82-10.87,12.64-6.29-.18-10.35-5.13-10.36-12.75q0-41.16,0-82.33c0-5.91,3-9.91,8-11.26a10.29,10.29,0,0,1,11.85,5.16,16.06,16.06,0,0,1,1.33,6.71c.12,13.8.06,27.61.06,41.41Z" transform="translate(-833 -413)"/><path d="M929,562.53q0,21,0,41.92c0,4.8-2.09,8.39-6.49,10.29-4.21,1.81-8.49,1.25-11.43-2.23a13.57,13.57,0,0,1-3.17-8c-.23-28.1-.19-56.21-.12-84.32,0-6.74,4.63-11.34,10.74-11.19s10.41,4.78,10.44,11.59C929.05,534.59,929,548.56,929,562.53Z" transform="translate(-833 -413)"/></svg>',
        action: removeLocalItem,
    },
    removeFromFavorite: {
        name: '删除',
        icon: '<svg width="16" height="16" viewBox="0 0 256 256" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg"><path d="M1040,669H882c-12.79-4.93-17.16-14.62-17.1-27.83.26-52.77.11-105.55.11-158.32V477c-6,0-11.42-.32-16.84.09-6.54.48-11.66-1.39-15.17-7.08v-7c3.16-5.7,8-7.48,14.44-7.36,18.29.32,36.58.12,54.88.1,1.75,0,3.5-.16,5.48-.25,0-7.76,0-14.91,0-22.05a18.56,18.56,0,0,1,6.6-14.52c2.85-2.39,6.37-4,9.59-5.92h73c13.83,5.64,17.27,10.84,17.25,26.08,0,5.41,0,10.82,0,16.68h7.53c17.61,0,35.21.2,52.81-.12,6.43-.12,11.27,1.63,14.41,7.36v7c-3.5,5.7-8.63,7.56-15.17,7.08-5.41-.4-10.89-.09-16.84-.09v6.36c0,52.6-.15,105.2.11,157.8C1057.17,654.36,1052.81,664.08,1040,669ZM886.24,477.29V640.4c0,8.44-.49,7.34,7.11,7.35q67.95,0,135.9,0c6.51,0,6.52,0,6.52-6.43v-164Zm106.5-42.78H929.37v21h63.37Z" transform="translate(-833 -413)"/><path d="M950.29,562.2c0-13.47,0-26.94,0-40.41,0-7.94,4.25-12.84,10.82-12.77,6.36.07,10.59,5,10.6,12.52,0,27.28,0,54.55,0,81.83,0,5.13-1.71,9.17-6.5,11.36-7.39,3.36-14.87-2.16-14.94-11.11-.11-13.81,0-27.61,0-41.42Z" transform="translate(-833 -413)"/><path d="M1014.25,562.63c0,13.48,0,27,0,40.42,0,7.88-4.3,12.82-10.87,12.64-6.29-.18-10.35-5.13-10.36-12.75q0-41.16,0-82.33c0-5.91,3-9.91,8-11.26a10.29,10.29,0,0,1,11.85,5.16,16.06,16.06,0,0,1,1.33,6.71c.12,13.8.06,27.61.06,41.41Z" transform="translate(-833 -413)"/><path d="M929,562.53q0,21,0,41.92c0,4.8-2.09,8.39-6.49,10.29-4.21,1.81-8.49,1.25-11.43-2.23a13.57,13.57,0,0,1-3.17-8c-.23-28.1-.19-56.21-.12-84.32,0-6.74,4.63-11.34,10.74-11.19s10.41,4.78,10.44,11.59C929.05,534.59,929,548.56,929,562.53Z" transform="translate(-833 -413)"/></svg>',
        action: removeFavoriteItem,
    },
    playCustom: {
        name: '播放歌单',
        icon: '<svg width="16" height="16" viewBox="0 0 139 139" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M117.037,61.441L36.333,14.846c-2.467-1.424-5.502-1.424-7.972,0c-2.463,1.423-3.982,4.056-3.982,6.903v93.188  c0,2.848,1.522,5.479,3.982,6.9c1.236,0.713,2.61,1.067,3.986,1.067c1.374,0,2.751-0.354,3.983-1.067l80.704-46.594  c2.466-1.422,3.984-4.054,3.984-6.9C121.023,65.497,119.502,62.866,117.037,61.441z"/></svg>',
        action: playCustom,
    },
    createCustom: {
        name: '新建歌单',
        icon: '<svg width="16" height="16" viewBox="0 0 768.02 554.57" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M341.9,0q148,0,296,0C659,0,675,11.28,680.8,30.05c8.34,26.78-11.43,54.43-39.45,55.18-1.17,0-2.33,0-3.5,0q-296.46,0-592.93,0C22.37,85.25,5.32,71.87.87,50.78-4.36,26,14.59,1.39,39.94.12c2.49-.13,5-.11,7.5-.11Z"/><path d="M554.64,426.5h-6.72c-26.49,0-53,.17-79.47-.1a41.87,41.87,0,0,1-39.06-27.7,42.4,42.4,0,0,1,11.2-46.19,41.85,41.85,0,0,1,29.11-11.25q39.49,0,79,0h6V335c0-26-.12-52,0-78,.15-25.3,19.44-44.3,44.06-43.72,23.23.55,41.24,19.54,41.37,43.92.13,25.82,0,51.65,0,77.48v6.57h5.67c26.65,0,53.31-.11,80,.05,20.38.12,37.94,14.9,41.51,34.49,3.74,20.57-7.15,40.65-26.59,47.73a53.72,53.72,0,0,1-17.56,2.85c-25.66.3-51.32.13-77,.13h-6v6.36c0,26,.1,52,0,78-.11,20.74-13.1,37.68-32.17,42.41-27.42,6.8-53-13.28-53.24-42.11-.22-26-.05-52-.05-78Z"/><path d="M234.37,256q-94.73,0-189.44,0c-21.55,0-38.62-12.68-43.5-32.09-6.74-26.8,12.45-52.1,40.47-53.35,1.33-.06,2.67-.05,4-.05H423.78c21.17,0,37.53,11.12,43.49,29.46,9.15,28.13-11.52,55.87-42,56-36.32.15-72.64,0-109,0Z"/><path d="M170.91,426.5c-42.48,0-85,.07-127.45,0-20.94-.06-37.61-13.2-42.21-32.85-6.18-26.41,13.5-52,40.6-52.3,23.82-.27,47.65-.07,71.47-.07q92.46,0,184.93,0c24.55,0,43.52,19.37,43.12,43.58-.38,23.41-19.15,41.53-43.51,41.61-40,.12-80,0-120,0Z"/></g></g></svg>',
        action: visitPlaylistCreate,
    },
    editCustom: {
        name: '编辑歌单',
        icon: '<svg width="16" height="16" viewBox="0 0 992.3 992.23" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M428.27,992.13c-88.16,0-176.32.28-264.48-.1-56.56-.24-101.65-23.86-134.6-69.78A150.76,150.76,0,0,1,.34,833.37C0,743.21.19,653.05.18,562.89c0-88-.5-176,.17-264C.82,236.36,29,188.83,82.63,156.81c25.32-15.11,53.25-21.18,82.69-21.15q161,.15,322,.06c26.66,0,45.78,15.33,50.38,40,5,26.58-15,53-41.88,55.53-3.31.31-6.66.42-10,.42q-159.75,0-319.49-.06c-25.45,0-45.64,9.41-59.78,30.75-7.47,11.29-10.42,23.92-10.41,37.45q.09,229.23,0,458.47,0,35.25,0,70.5c.06,38.34,29,67.32,67.42,67.33q264.74,0,529.47,0c38.53,0,67.21-28.52,67.44-67.25.21-32.66.05-65.33.05-98q0-112.74,0-225.49c0-19.14,7-34.41,23.5-44.58,30.3-18.63,70.25,2.33,72.32,37.83.13,2.17.21,4.33.21,6.5q0,161.24,0,322.48c0,47.47-16.82,87.91-51.29,120.5-30,28.4-66.18,43.56-107.53,43.81-89.83.52-179.66.16-269.49.16Z"/><path d="M417,473.1c1.08-20.29,2.1-40.59,3.27-60.88a46.93,46.93,0,0,1,11.63-28.62c1.74-2,3.64-3.89,5.53-5.78L798.28,16.91c22.51-22.5,50.7-22.57,73.22-.07q52.15,52.11,104.27,104.27c22,22,22.06,50.57.07,72.54Q794.42,374.91,613,556.14c-10.34,10.34-22.49,15.36-37,16.06q-50.93,2.47-101.8,5.69c-14.62.91-28.69.35-40.88-9.11-12.48-9.69-19.48-22.41-19.12-38.27.43-19.15,1.73-38.28,2.65-57.41Zm95.78,6.38c13.28-.76,25.7-1.6,38.15-2.09a12.52,12.52,0,0,0,9.12-4q156.09-156.07,312.3-312c1.26-1.26,2.43-2.58,3.23-3.43l-41.31-41.26-72.48,72.49Q640.15,310.8,518.56,432.44c-1.44,1.45-3.22,3.37-3.35,5.18C514.19,451.23,513.55,464.86,512.74,479.48Z"/></g></g></svg>',
        action: visitCustomEdit,
    },
    batchCustom: {
        name: '批量操作',
        icon: '<svg width="15" height="15" viewBox="0 0 160 125" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M55,20h95a10,10,0,0,0,0-20H55a10,10,0,0,0,0,20ZM20,0H10a10,10,0,0,0,0,20H20A10,10,0,0,0,20,0ZM55,70h75a10,10,0,0,0,0-20H55a10,10,0,0,0,0,20ZM20,50H10a10,10,0,0,0,0,20H20a10,10,0,0,0,0-20Zm130,55H55a10,10,0,0,0,0,20h95a10,10,0,0,0,0-20ZM20,105H10a10,10,0,0,0,0,20H20a10,10,0,0,0,0-20Z"/></g></g></svg>',
        action: visitBatchCustom,
    },
    removeCustom: {
        name: '删除',
        icon: '<svg width="16" height="16" viewBox="0 0 256 256" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg"><path d="M1040,669H882c-12.79-4.93-17.16-14.62-17.1-27.83.26-52.77.11-105.55.11-158.32V477c-6,0-11.42-.32-16.84.09-6.54.48-11.66-1.39-15.17-7.08v-7c3.16-5.7,8-7.48,14.44-7.36,18.29.32,36.58.12,54.88.1,1.75,0,3.5-.16,5.48-.25,0-7.76,0-14.91,0-22.05a18.56,18.56,0,0,1,6.6-14.52c2.85-2.39,6.37-4,9.59-5.92h73c13.83,5.64,17.27,10.84,17.25,26.08,0,5.41,0,10.82,0,16.68h7.53c17.61,0,35.21.2,52.81-.12,6.43-.12,11.27,1.63,14.41,7.36v7c-3.5,5.7-8.63,7.56-15.17,7.08-5.41-.4-10.89-.09-16.84-.09v6.36c0,52.6-.15,105.2.11,157.8C1057.17,654.36,1052.81,664.08,1040,669ZM886.24,477.29V640.4c0,8.44-.49,7.34,7.11,7.35q67.95,0,135.9,0c6.51,0,6.52,0,6.52-6.43v-164Zm106.5-42.78H929.37v21h63.37Z" transform="translate(-833 -413)"/><path d="M950.29,562.2c0-13.47,0-26.94,0-40.41,0-7.94,4.25-12.84,10.82-12.77,6.36.07,10.59,5,10.6,12.52,0,27.28,0,54.55,0,81.83,0,5.13-1.71,9.17-6.5,11.36-7.39,3.36-14.87-2.16-14.94-11.11-.11-13.81,0-27.61,0-41.42Z" transform="translate(-833 -413)"/><path d="M1014.25,562.63c0,13.48,0,27,0,40.42,0,7.88-4.3,12.82-10.87,12.64-6.29-.18-10.35-5.13-10.36-12.75q0-41.16,0-82.33c0-5.91,3-9.91,8-11.26a10.29,10.29,0,0,1,11.85,5.16,16.06,16.06,0,0,1,1.33,6.71c.12,13.8.06,27.61.06,41.41Z" transform="translate(-833 -413)"/><path d="M929,562.53q0,21,0,41.92c0,4.8-2.09,8.39-6.49,10.29-4.21,1.81-8.49,1.25-11.43-2.23a13.57,13.57,0,0,1-3.17-8c-.23-28.1-.19-56.21-.12-84.32,0-6.74,4.63-11.34,10.74-11.19s10.41,4.78,10.44,11.59C929.05,534.59,929,548.56,929,562.53Z" transform="translate(-833 -413)"/></svg>',
        action: removeCustom,
    },
    removeFromCustom: {
        name: '删除',
        icon: '<svg width="16" height="16" viewBox="0 0 256 256" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg"><path d="M1040,669H882c-12.79-4.93-17.16-14.62-17.1-27.83.26-52.77.11-105.55.11-158.32V477c-6,0-11.42-.32-16.84.09-6.54.48-11.66-1.39-15.17-7.08v-7c3.16-5.7,8-7.48,14.44-7.36,18.29.32,36.58.12,54.88.1,1.75,0,3.5-.16,5.48-.25,0-7.76,0-14.91,0-22.05a18.56,18.56,0,0,1,6.6-14.52c2.85-2.39,6.37-4,9.59-5.92h73c13.83,5.64,17.27,10.84,17.25,26.08,0,5.41,0,10.82,0,16.68h7.53c17.61,0,35.21.2,52.81-.12,6.43-.12,11.27,1.63,14.41,7.36v7c-3.5,5.7-8.63,7.56-15.17,7.08-5.41-.4-10.89-.09-16.84-.09v6.36c0,52.6-.15,105.2.11,157.8C1057.17,654.36,1052.81,664.08,1040,669ZM886.24,477.29V640.4c0,8.44-.49,7.34,7.11,7.35q67.95,0,135.9,0c6.51,0,6.52,0,6.52-6.43v-164Zm106.5-42.78H929.37v21h63.37Z" transform="translate(-833 -413)"/><path d="M950.29,562.2c0-13.47,0-26.94,0-40.41,0-7.94,4.25-12.84,10.82-12.77,6.36.07,10.59,5,10.6,12.52,0,27.28,0,54.55,0,81.83,0,5.13-1.71,9.17-6.5,11.36-7.39,3.36-14.87-2.16-14.94-11.11-.11-13.81,0-27.61,0-41.42Z" transform="translate(-833 -413)"/><path d="M1014.25,562.63c0,13.48,0,27,0,40.42,0,7.88-4.3,12.82-10.87,12.64-6.29-.18-10.35-5.13-10.36-12.75q0-41.16,0-82.33c0-5.91,3-9.91,8-11.26a10.29,10.29,0,0,1,11.85,5.16,16.06,16.06,0,0,1,1.33,6.71c.12,13.8.06,27.61.06,41.41Z" transform="translate(-833 -413)"/><path d="M929,562.53q0,21,0,41.92c0,4.8-2.09,8.39-6.49,10.29-4.21,1.81-8.49,1.25-11.43-2.23a13.57,13.57,0,0,1-3.17-8c-.23-28.1-.19-56.21-.12-84.32,0-6.74,4.63-11.34,10.74-11.19s10.41,4.78,10.44,11.59C929.05,534.59,929,548.56,929,562.53Z" transform="translate(-833 -413)"/></svg>',
        action: removeFromCustom,
    },
    removeFromRecent: {
        name: '删除',
        icon: '<svg width="16" height="16" viewBox="0 0 256 256" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg"><path d="M1040,669H882c-12.79-4.93-17.16-14.62-17.1-27.83.26-52.77.11-105.55.11-158.32V477c-6,0-11.42-.32-16.84.09-6.54.48-11.66-1.39-15.17-7.08v-7c3.16-5.7,8-7.48,14.44-7.36,18.29.32,36.58.12,54.88.1,1.75,0,3.5-.16,5.48-.25,0-7.76,0-14.91,0-22.05a18.56,18.56,0,0,1,6.6-14.52c2.85-2.39,6.37-4,9.59-5.92h73c13.83,5.64,17.27,10.84,17.25,26.08,0,5.41,0,10.82,0,16.68h7.53c17.61,0,35.21.2,52.81-.12,6.43-.12,11.27,1.63,14.41,7.36v7c-3.5,5.7-8.63,7.56-15.17,7.08-5.41-.4-10.89-.09-16.84-.09v6.36c0,52.6-.15,105.2.11,157.8C1057.17,654.36,1052.81,664.08,1040,669ZM886.24,477.29V640.4c0,8.44-.49,7.34,7.11,7.35q67.95,0,135.9,0c6.51,0,6.52,0,6.52-6.43v-164Zm106.5-42.78H929.37v21h63.37Z" transform="translate(-833 -413)"/><path d="M950.29,562.2c0-13.47,0-26.94,0-40.41,0-7.94,4.25-12.84,10.82-12.77,6.36.07,10.59,5,10.6,12.52,0,27.28,0,54.55,0,81.83,0,5.13-1.71,9.17-6.5,11.36-7.39,3.36-14.87-2.16-14.94-11.11-.11-13.81,0-27.61,0-41.42Z" transform="translate(-833 -413)"/><path d="M1014.25,562.63c0,13.48,0,27,0,40.42,0,7.88-4.3,12.82-10.87,12.64-6.29-.18-10.35-5.13-10.36-12.75q0-41.16,0-82.33c0-5.91,3-9.91,8-11.26a10.29,10.29,0,0,1,11.85,5.16,16.06,16.06,0,0,1,1.33,6.71c.12,13.8.06,27.61.06,41.41Z" transform="translate(-833 -413)"/><path d="M929,562.53q0,21,0,41.92c0,4.8-2.09,8.39-6.49,10.29-4.21,1.81-8.49,1.25-11.43-2.23a13.57,13.57,0,0,1-3.17-8c-.23-28.1-.19-56.21-.12-84.32,0-6.74,4.63-11.34,10.74-11.19s10.41,4.78,10.44,11.59C929.05,534.59,929,548.56,929,562.53Z" transform="translate(-833 -413)"/></svg>',
        action: removeFromRecent,
    },
    playPlaylist: {
        name: '播放歌单',
        icon: '<svg width="16" height="16" viewBox="0 0 139 139" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M117.037,61.441L36.333,14.846c-2.467-1.424-5.502-1.424-7.972,0c-2.463,1.423-3.982,4.056-3.982,6.903v93.188  c0,2.848,1.522,5.479,3.982,6.9c1.236,0.713,2.61,1.067,3.986,1.067c1.374,0,2.751-0.354,3.983-1.067l80.704-46.594  c2.466-1.422,3.984-4.054,3.984-6.9C121.023,65.497,119.502,62.866,117.037,61.441z"/></svg>',
        action: () => doPlayPlaylist(commonCtxMenuCacheItem.value),
    },
    removePlaylistFromFavorite: {
        name: '删除',
        icon: '<svg width="16" height="16" viewBox="0 0 256 256" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg"><path d="M1040,669H882c-12.79-4.93-17.16-14.62-17.1-27.83.26-52.77.11-105.55.11-158.32V477c-6,0-11.42-.32-16.84.09-6.54.48-11.66-1.39-15.17-7.08v-7c3.16-5.7,8-7.48,14.44-7.36,18.29.32,36.58.12,54.88.1,1.75,0,3.5-.16,5.48-.25,0-7.76,0-14.91,0-22.05a18.56,18.56,0,0,1,6.6-14.52c2.85-2.39,6.37-4,9.59-5.92h73c13.83,5.64,17.27,10.84,17.25,26.08,0,5.41,0,10.82,0,16.68h7.53c17.61,0,35.21.2,52.81-.12,6.43-.12,11.27,1.63,14.41,7.36v7c-3.5,5.7-8.63,7.56-15.17,7.08-5.41-.4-10.89-.09-16.84-.09v6.36c0,52.6-.15,105.2.11,157.8C1057.17,654.36,1052.81,664.08,1040,669ZM886.24,477.29V640.4c0,8.44-.49,7.34,7.11,7.35q67.95,0,135.9,0c6.51,0,6.52,0,6.52-6.43v-164Zm106.5-42.78H929.37v21h63.37Z" transform="translate(-833 -413)"/><path d="M950.29,562.2c0-13.47,0-26.94,0-40.41,0-7.94,4.25-12.84,10.82-12.77,6.36.07,10.59,5,10.6,12.52,0,27.28,0,54.55,0,81.83,0,5.13-1.71,9.17-6.5,11.36-7.39,3.36-14.87-2.16-14.94-11.11-.11-13.81,0-27.61,0-41.42Z" transform="translate(-833 -413)"/><path d="M1014.25,562.63c0,13.48,0,27,0,40.42,0,7.88-4.3,12.82-10.87,12.64-6.29-.18-10.35-5.13-10.36-12.75q0-41.16,0-82.33c0-5.91,3-9.91,8-11.26a10.29,10.29,0,0,1,11.85,5.16,16.06,16.06,0,0,1,1.33,6.71c.12,13.8.06,27.61.06,41.41Z" transform="translate(-833 -413)"/><path d="M929,562.53q0,21,0,41.92c0,4.8-2.09,8.39-6.49,10.29-4.21,1.81-8.49,1.25-11.43-2.23a13.57,13.57,0,0,1-3.17-8c-.23-28.1-.19-56.21-.12-84.32,0-6.74,4.63-11.34,10.74-11.19s10.41,4.78,10.44,11.59C929.05,534.59,929,548.56,929,562.53Z" transform="translate(-833 -413)"/></svg>',
        action: removePlaylistFromFavorite,
    },
    searchTrackResource: {
        name: '搜索歌曲资源',
        icon: '<svg width="16" height="16" viewBox="0 0 726.24 726.5" xmlns="http://www.w3.org/2000/svg"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path d="M456.25,529.61C384.86,577,307.37,592.47,224,573.24,153.93,557.08,97.62,519,55.17,460.86-28.43,346.44-15.75,186.09,84.6,85.69c101.34-101.4,261-114.38,376.23-30.54,41.42,30.13,73,68.4,94.17,115.09,21.07,46.46,29.25,95.18,24.9,146-4.37,51-21.59,97.46-51.33,141.2,1.68,1.06,3.67,1.85,5,3.23Q622,549.41,710.24,638.25c14.25,14.32,19.28,31.43,13.88,50.84-10.61,38.09-57.48,50-86,22-23.29-22.9-46.23-46.15-69.33-69.24L459.56,532.66C458.52,531.62,457.4,530.67,456.25,529.61Zm56.64-238.83C513,168.29,413.34,68.68,290.67,68.67a221.82,221.82,0,0,0-222,222.1c0,122.25,99.47,221.82,221.82,222.16C412.61,513.26,512.77,413.22,512.89,290.78Z" /></g></g></svg>',
        action: showTrackResourceToolView,
    }
}

const doInit = (data) => {
    hideAllCtxMenus()
    setCommonCtxMenuData(data)
}

const isLocalMusicType = (dataType) => (dataType == 10)

const addToAction = (dataType, item) => {
    const tracks = []
    const cache = commonCtxMenuCacheItem.value
    if (Array.isArray(cache)) {
        tracks.push(...cache)
    } else {
        tracks.push(item)
    }
    const action = isLocalMusicType(dataType) ? addToLocalPlaylist : addToCustomPlaylist
    if (action) {
        tracks.forEach(track => {
            action(item.id, track)
        })
        toastAndHideMenu("歌曲添加成功")
    }
}

const moveToAction = (dataType, item) => {
    const tracks = []
    const cache = commonCtxMenuCacheItem.value
    if (Array.isArray(cache)) {
        tracks.push(...cache)
    } else {
        tracks.push(item)
    }
    const { id: fromId } = commonCtxItem.value
    const { id: toId } = item

    const action = isLocalMusicType(dataType) ? moveToLocalPlaylist : moveToCustomPlaylist
    if (action) {
        tracks.forEach(track => {
            action(toId, fromId, track)
        })
        toastAndHideMenu("歌曲移动成功")
    }
}

//已废弃
const initBatchActionPopupMenuData = (dataType, isMoveAction) => {
    const data = []
    const fixedItems = [MenuItems.addToQueue, MenuItems.createCustom]
    isMoveAction ? data.push(fixedItems[1]) : data.push(...fixedItems)
    const playlists = isLocalMusicType(dataType) ? localPlaylists.value : customPlaylists.value

    playlists.forEach(item => {
        //跳过自身
        if (commonCtxItem.value && commonCtxItem.value.id == item.id) return
        data.push({
            name: item.title,
            action: (event) => {
                isMoveAction ? moveToAction(dataType, item) : addToAction(dataType, item)
            },
        })
    })
    return data
}

const showSubmenu = (item, index, event) => {
    //TODO
    emitEvents("addToListSubmenu-hide", event)
    emitEvents("artistListSubmenu-hide", event)
    if (!item || !item.menu || !item.menu()) {
        return
    }
    const { action } = item
    if (action) action(event)
}

const visitMenuItem = (item, index, event) => {
    if (!item || !item.action) return
    const { action } = item
    if (typeof action == 'function') {
        const needTriggerEvent = action(item, index, event)
        if (needTriggerEvent) emitEvents("commonCtxMenuItem-finish")
    }
}

const initCommonCtxMenu = ({ dataType, actionType }) => {
    currentDataType = dataType || 0
    let data = []
    switch (dataType) {
        case 0: //在线音乐平台 - 歌单页、歌手页、专辑页 - 普通歌曲列表
            data = [MenuItems.play, MenuItems.playLater,
            MenuItems.sp, MenuItems.addToList, MenuItems.addFavorite,
            MenuItems.sp, MenuItems.visitArtist, MenuItems.visitAlbum,
            MenuItems.visitTrack]
            break;
        case 1: //本地歌曲 - 歌单页 - 歌曲列表
            const addToQueueMenuItem = Object.assign({}, { ...MenuItems.addToQueue })
            addToQueueMenuItem.name = "添加到当前播放"
            data = [MenuItems.play, addToQueueMenuItem, MenuItems.playLater, MenuItems.searchTrackResource,
            MenuItems.sp, MenuItems.addToList, MenuItems.moveToList,
            MenuItems.sp, MenuItems.visitArtist, MenuItems.visitAlbum, MenuItems.visitTrack, MenuItems.showInFolder,
            MenuItems.sp, MenuItems.removeFromLocal]
            break;
        case 2: //我的主页 - 我的收藏 - 歌曲列表
            data = [MenuItems.play, MenuItems.playLater, MenuItems.searchTrackResource, MenuItems.addToList,
            MenuItems.sp, MenuItems.visitArtist, MenuItems.visitAlbum, MenuItems.visitTrack,
            MenuItems.sp, MenuItems.removeFromFavorite,]
            break;
        case 3: //我的主页 - 创建的歌单 - 歌单列表
            data = [MenuItems.playCustom, MenuItems.editCustom,
            MenuItems.batchCustom, MenuItems.removeCustom]
            break;
        case 4: //创建的歌单 - 歌曲列表
            data = [MenuItems.play, MenuItems.playLater, MenuItems.searchTrackResource,
            MenuItems.sp, MenuItems.addToList, MenuItems.moveToList, MenuItems.addFavorite,
            MenuItems.sp, MenuItems.visitArtist, MenuItems.visitAlbum, MenuItems.visitTrack,
            MenuItems.sp, MenuItems.removeFromCustom]
            break;
        case 5: //我的主页 - 最近播放 - 歌曲列表
            data = [MenuItems.play, MenuItems.playLater, MenuItems.addToList, MenuItems.addFavorite, ,
            MenuItems.sp, MenuItems.visitArtist, MenuItems.visitAlbum, MenuItems.visitTrack,
            MenuItems.sp, MenuItems.removeFromRecent,]
            break;
        case 6: //我的主页 - 批量操作 - 添加到菜单、移动到菜单
            data = initBatchActionPopupMenuData(dataType, actionType == 1)
            break;
        case 8: //首页-收藏的歌单
            data = [MenuItems.playPlaylist, MenuItems.removePlaylistFromFavorite]
            break;
        case 9: //当前播放列表
            if(isMiniLayout.value) {
                data = [MenuItems.play, MenuItems.playLater, MenuItems.searchTrackResource,
                    MenuItems.sp, MenuItems.visitAlbum, MenuItems.visitTrack, 
                    MenuItems.sp, MenuItems.removeFromQueue,]
            } else {
                data = [MenuItems.play, MenuItems.playLater, MenuItems.searchTrackResource,
                    MenuItems.sp, MenuItems.addToListNoQueue(), MenuItems.addAllToListNoQueue(), MenuItems.addFavorite, /*MenuItems.share,*/
                    MenuItems.sp, MenuItems.visitArtist, MenuItems.visitAlbum,
                    MenuItems.sp, MenuItems.visitTrack, MenuItems.removeFromQueue,]
            }
            break;
        case 10: //本地歌曲 - 批量操作 - 添加到菜单、移动到菜单 
            data = initBatchActionPopupMenuData(dataType, actionType == 1)
            break;
        case 11: //本地歌曲 - 歌手页、专辑页 - 歌曲列表
            data = [MenuItems.play, MenuItems.playLater, MenuItems.searchTrackResource,
            /*MenuItems.sp, MenuItems.addToList, MenuItems.addFavorite,*/
            MenuItems.sp, MenuItems.visitArtist, MenuItems.visitAlbum, MenuItems.visitTrack, MenuItems.showInFolder,
            MenuItems.sp, MenuItems.removeFromLocal,]
            break;
        case 12: //我的主页 - 播放队列 - 详情
            data = [MenuItems.play, MenuItems.playLater, MenuItems.searchTrackResource,
            MenuItems.sp, MenuItems.visitArtist, MenuItems.visitAlbum, MenuItems.visitTrack, ]
            break;
    }
    doInit(data)
}


/* 生命周期、监听 */
const eventsRegistration = {
    'commonCtxMenu-init': initCommonCtxMenu,
}
onMounted(() => onEvents(eventsRegistration))
onUnmounted(() => offEvents(eventsRegistration))
</script>

<template>
    <div class="common-ctx-menu" :style="posStyle" @click.stop="">
        <div class="container">
            <div class="padding"></div>
            <div class="center">
                <template v-for="(item, index) in data">
                    <div class="menuItem" @mouseenter="(event) => showSubmenu(item, index, event)"
                        @click="(event) => visitMenuItem(item, index, event)" v-show="!item.separator">
                        <div v-html="item.icon"></div>
                        <div><span>{{ item.name }}</span></div>
                    </div>
                    <div class="separator" v-show="item.separator && false"></div>
                </template>
            </div>
            <div class="padding"></div>
        </div>
    </div>
</template>

<style>
.common-ctx-menu {
    position: absolute;
    z-index: 101;
    display: flex;
    /*flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border-color);*/
    box-shadow: 0px 0px 6px var(--border-popovers-border-color);
    max-height: 505px;
}

.common-ctx-menu .container {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /*border-radius: 8px;*/
    background: var(--content-bg-color);
    background: var(--content-bg-color-no-transparent);
}

.common-ctx-menu .padding {
    height: 10px;
}

.common-ctx-menu .center {
    overflow: auto;
}

.common-ctx-menu .menuItem {
    /*width: 168px;*/
    width: 178px;
    display: flex;
    flex-direction: row;
    align-items: center;
    /* font-size: 14px; */
    font-size: var(--content-text-subtitle-size);
    padding: 9px 25px;
    height: 23px;
}

.common-ctx-menu .menuItem:hover {
    background-color: var(--content-subtitle-text-color);
    /*
    background: var(--button-icon-text-btn-bg-color);
    color: var(--button-icon-text-btn-icon-color);
    */
    background: var(--content-list-item-hl-bg-color);
    color: var(--content-list-item-hl-text-color);
    cursor: pointer;
}

.common-ctx-menu .menuItem:hover svg {
    fill: var(--button-icon-text-btn-icon-color);
}

.common-ctx-menu .menuItem > div {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.common-ctx-menu .menuItem svg {
    margin-right: 10px;
    fill: var(--content-text-color);
}

.common-ctx-menu .menuItem span {
    overflow: hidden;
    word-wrap: break-all;
    white-space: pre-wrap;
    line-break: anywhere;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    text-align: left;
    word-wrap: break-word;
    line-break: anywhere;
}

.common-ctx-menu .separator {
    margin: 3px 15px;
    height: 0px;
    border-bottom: 0.36px solid var(--border-color);
}

.contrast-mode .common-ctx-menu .menuItem:hover {
    font-weight: bold;
}
</style>